
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>浙江数字人社工作台</title>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="SHORTCUT ICON" href="/sso/images/favicon.ico" type="image/x-icon" />
<script src="../js/tz_cfg.js?version=2.0.6" type="text/javascript"></script>
<script type="text/javascript">tz.cfg.base="/sso"</script>
<!--[if lt IE 10]>
<script src="/sso/libs/es5-shim.min.js?version=2.0.6" type="text/javascript"></script>
<script src="/sso/libs/es5-sham.min.js?version=2.0.6" type="text/javascript"></script>
<![endif]-->



<!-- <script src="../js/scripts/jquery.min.js"type="text/javascript"></script> -->
<!-- <script src="../js/scripts/miniui/miniui.js"type="text/javascript"></script> -->
<!-- <script src="../js/scripts/miniui/tz_mini.js"type="text/javascript"></script> -->
<!-- <script src="../js/scripts/jquery.min.js"type="text/javascript"></script> -->
<script src="../js/scripts/boot.js"type="text/javascript"></script>

<!-- 引入MiniUI的样式 -->
<!-- <link href="../plugin/miniui/default/miniui.css" rel="stylesheet" type="text/css" /> -->
<link href="../plugin/miniui/default/medium-mode.css" rel="stylesheet" type="text/css" />

<link href="../js/scripts/miniui/themes/default/miniui.css" rel="stylesheet" type="text/css" />
<link href="../css/common_ext.css" rel="stylesheet" type="text/css" />
<link href="../css/common.css" rel="stylesheet" type="text/css" />

<link href="../css/mgr/baseStyle.css" rel="stylesheet" type="text/css" />
<link href="../css/color.css" rel="stylesheet" type="text/css" />
<link href="../css/skin.css" rel="stylesheet" type="text/css" />
<link href="../css/tz-skin.css" rel="stylesheet" type="text/css" />


<!-- <script src="../js/component/component.js?version=2.0.6" type="text/javascript"></script> -->
</head>
<body>
    <style>
        .grayBtn {}
    </style>
    <link rel="stylesheet" href="../css/mgr/baseStyle.css?v=2.0.0">
    <div class="mini-layout mainCon">
        <div region="west" showHeader="false" style="border:0px" showSplitIcon="false" width="360px">
            <div class="mini-fit line">
                <div class="mini-toolbar" borderStyle="border:0">
                    <div class="btnCon">
                        <input id="searchOrgKey" class="mini-textbox" onenter="searchOrgByKey()" width="170" emptytext="请输入机构名称">
                        <a class="mini-button blueBtn" onclick="searchOrgByKey()" tooltip="查询">查询</a>
                        <a class="mini-button reload blueBtn" onclick="resetSearchOrgByKey()" tooltip="重置">重置</a>
                    </div>
                </div>
                <div class="mini-fit" style="width: 95%;">
                    <ul id="tree" class="mini-tree" url="../json/gridTest.json" style="width:100%; height: 100%; padding:5px;" ajaxOptions="{async:true}" showTreeIcon="true" resultAsTree="false" expandOnLoad="1" textField="aab300" idField="bsc001"
                        parentField="bsc110" onnodeclick="onTreeNodeClick" onbeforeload="onBeforeTreeLoad" onpreload="onPreLoadTree">
                    </ul>
                </div>
            </div>
        </div>
        <div region="center" width="auto" style="border:0px">
            <div class="mini-toolbar" borderStyle="border:0" style=" padding-top:11px;">
                <table id="searchUserForm" style="width:100%;">
                    <tr style="width: 100%">
                        <td style="white-space:nowrap;" class="mini-col-4">
                            <input class="mini-textbox" labelField="true" label="用户" labelStyle="width:80px" id="searchUserKey" name="searchUserKey" width="95%" maxLength="50" onenter="searchUser()" emptyText="请输入用户名/姓名/身份证号" />
                        </td>
                        <td class="mini-col-4">
                            <input name="bsc001" class="mini-org" labelField="true" label="所属机构" labelStyle="width:80px" emptyText="请输入所属机构" width="95%" onenter="searchUser()" />
                        </td>
                        <td class="mini-col-4">
                            <input class="mini-textbox" id="bsc071" name="bsc071" maxLength="11" labelField="true" label="手机号码" labelStyle="width:80px" width="95%" onenter="searchUser()" emptyText="请输入用户手机号" />
                        </td>
                    </tr>
                    <tr>
                        <td class="mini-col-4">
                            <input class="mini-combobox" id="certRealName" name="certRealName" labelStyle="width:80px" labelField="true" label="是否实名" width="95%" showNullItem="true" allowInput="false" textField="text" valueField="id" data='[{"id":"0","text":"否"},{"id":"1","text":"是"}]' />
                        </td>
                        <td class="mini-col-4">
                            <input class="mini-combobox" name="status" id="status" labelStyle="width:80px" labelField="true" label="账号状态" width="95%" showNullItem="true" allowInput="false" textField="text" valueField="id" data="[{'id':'normal','text':'正常'},{'id':'locked','text':'已锁定'},{'id':'cancel','text':'已注销'}]"
                            />
                        </td>
                        <td class="mini-col-4">
                            <input class="mini-combobox" id="accountUsage" name="accountUsage" labelStyle="width:80px" labelField="true" label="账号使用情况" width="95%"
                               textField="text" valueField="id" data='[{"id":"0","text":"不活跃"},{"id":"1","text":"活跃"},{"id":"2","text":"1个月以上未登录"},{"id":"3","text":"3个月以上未登录"},{"id":"4","text":"半年以上未登录"},{"id":"5","text":"一年以上未登录"}]' showNullItem="true" allowInput="false" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <a class="mini-button blueBtn" onclick="searchUser()">查询</a>
                            <a class="mini-button reload blueBtn" onclick="resetSearchUser()">重置</a>
                            <a class="mini-button reload icon" iconCls="fa fa-plus" onclick="onAdd()" tooltip="增加...">增加</a>
                            <a class="mini-button reload icon" iconCls="fa fa-exchange" onclick="onBatchPushUser()" tooltip="推送...">批量推送</a>
                        </td>
                    </tr>
                </table>
            </div>
            <div class="mini-fit" borderStyle="border:0">
                <div id="grid" borderStyle="border:0" showHGridLines="false" showVGridLines="false" class="mini-datagrid" width="100%" height="100%" url="../json/gridTest.json" pageSize="15" autoLoad="true" onpreload="preLoadGrid">
                    <div property="columns">
                        <div type="indexcolumn" width="40" headeralign="center" align="center">序号</div>
                        <div field="bsc010" headeralign="center" width="60" align="center">用户内码</div>
                        <div field="bsc011" headeralign="center" width="80" align="center">用户名</div>
                        <div field="bsc012" headeralign="center" width="60" align="center">姓名</div>
                        <div field="aab300" headeralign="center" width="140" align="center">所属机构</div>
                        <div field="#" headeralign="center" align="center" width="60" align="center" renderer="onStatusRenderer">账号状态</div>
                        <div field="#" headeralign="center" width="220" align="center" renderer="onRenderer" align="center">
                            操作
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script type="text/javascript">
        mini.parse();
        var grid = tz.get('grid');
        var tree = tz.get("tree");
        var searchUserForm = tz.form("#searchUserForm");

        function onBeforeTreeLoad(e) {
            var tree = e.sender; //树控件
            var node = e.node; //当前节点
            var params = e.params; //参数对象

            //可以传递自定义的属性
            params.bsc110 = node.bsc001; //后台：request对象获取"myField"

        }

        function onPreLoadTree(e) {
            var data = e.data;
            for (var i = 0; i < data.length; i++) {
                var item = data[i];
                if (item.aaa020) {
                    item.aab300 = (item.aab300 + "(" + item.aaa020 + ")");
                }
            }
        }

        //查询机构树
        function searchOrgByKey() {
            var searchOrgKey = tz.get("searchOrgKey").getValue();
            if (searchOrgKey) {
                tree.load(tz.url("/sys/org/queryManagerTreeByName", {
                    searchOrgKey: searchOrgKey
                }));
            } else {
                tree.load(tz.url("/sys/org/queryManagerLazyTree"));
            }
        }

        //重置查询条件及机构树
        function resetSearchOrgByKey() {
            tz.get("searchOrgKey").setValue("");
            searchOrgByKey();
        }

        function onTreeNodeClick(e) {
            var bbb003 = e.record.bbb003;
            grid.setUrl(tz.url("/sys/user/page", {
                bbb003: bbb003
            }));
            searchUserForm.reset();
            grid.reload();
        }

        function searchUser() {
            var param = searchUserForm.getData();
            var status = param.status;
            if (status == "normal") {
                param.aae100 = '1';
                param.locked = '1';
            } else if (status == 'locked') {
                param.aae100 = '1';
                param.locked = '0';
            } else if (status == 'cancel') {
                param.aae100 = '0';
                param.locked = '1';
            }
            grid.load(param);
        }

        function resetSearchUser() {
            searchUserForm.reset();
            searchUser();
        }

        grid.addRow({});

        function preLoadGrid(e) {
            var data = e.data;
            for (var i = 0; i < data.length; i++) {
                var item = data[i];
                if (item.aaa020) {
                    item.aab300 = (item.aab300 + "(" + item.aaa020 + ")");
                }
            }
        }

        function onRenderer(e) {
            var htmlStr;
            var record = e.record;
            if (record.aae100 != 1) {
                htmlStr = '<a class="gridBtn" style="color: gray">编辑</a><a class="gridBtn" style="color: gray">重置密码</a>';
                if (record.locked == '0') {
                    htmlStr += '<a class="gridBtn" style="color: gray">解锁</a>';
                } else {
                    htmlStr += '<a class="gridBtn" style="color: gray">锁定</a>';
                }
                htmlStr += '<a class="gridBtn" onclick="onRestore()">恢复</a>';
            } else {
                htmlStr = '<a class="gridBtn" onclick="onEdit()">编辑</a><a class="gridBtn" onclick="onResetPassword()">重置密码</a>';
                if (record.locked == '0') {
                    htmlStr += '<a class="gridBtn" onclick="unlocked()">解锁</a>';
                } else {
                    htmlStr += '<a class="gridBtn" onclick="locked()">锁定</a>';
                }
                htmlStr += '<a class="gridBtn" onclick="onCancel()">注销</a>';
            }
            htmlStr += '<a class="gridBtn" onclick="onRemove()">删除</a>';
            return htmlStr;
        }

        function onStatusRenderer(e) {
            var record = e.record;
            if (record.aae100 != '1') {
                return "<span style='color:gray'>已注销</span>";
            } else if (record.locked == '0') {
                return "<span style='color:red'>已锁定</span>";
            } else {
                return "<span style='color:green'>正常</span>";
            }
        }

        function onAdd() {
            var org = tree.getSelectedNode();
            var editUserUrl;
            if (org) {
                editUserUrl = tz.url('/sys/user/editor', {
                    bsc001: org.bsc001
                });
            } else {
                editUserUrl = tz.url('/sys/user/editor');
            }
            tz.open('新增', editUserUrl, function(pw) {
                grid.reload();
            }, {
                height: 620,
                width: 750
            })
        }

        function onBatchPushUser() {
            tz.open('用户推送', tz.url("/sys/user/batchPushUser"), function(pw) {

            }, {
                height: 620,
                width: 1080
            });
        }

        function onEdit(bsc010) {
            var row = grid.getSelected();
            if (row.aae100 == '0') {
                return tz.notify('已注销的账号不能编辑！');
            }
            var editUserUrl = tz.url('/sys/user/editor', {
                bsc010: row.bsc010
            });
            tz.open("编辑", editUserUrl, function(pw) {
                grid.reload();
            }, {
                height: 620,
                width: 750
            })
        }

        function onRemove() {
            var row = grid.getSelected();
            if (!row) {
                return tz.notify('请先选择需要删除的记录！');
            }
            tz.confirm('确定删除选中的用户信息吗？', function() {
                tz.ajax('/sys/user/delete', {
                    bsc010: row.bsc010
                }, function(obj) {
                    if (obj.success) {
                        grid.reload();
                    }
                })
            });
        }

        function onCancel() {
            var row = grid.getSelected();
            tz.confirm('确定注销选中的用户信息吗？', function() {
                tz.ajax('/sys/user/cancel', {
                    bsc010: row.bsc010
                }, function(obj) {
                    if (obj.success) {
                        grid.reload();
                    }
                })
            });
        }

        function onRestore() {
            var row = grid.getSelected();
            tz.confirm('确定恢复选中的用户信息吗？', function() {
                tz.ajax('/sys/user/restore', {
                    bsc010: row.bsc010
                }, function(obj) {
                    if (obj.success) {
                        grid.reload();
                    }
                })
            });
        }

        function locked() {
            var row = grid.getSelected();
            if (row.aae100 == '0') {
                return tz.notify('已注销的账号不能锁定账号！');
            }
            tz.confirm('确定锁定选中的用户信息吗？', function() {
                tz.ajax('/sys/user/locked', {
                    bsc010: row.bsc010
                }, function(obj) {
                    if (obj.success) {
                        grid.reload();
                    }
                })
            });
        }

        function unlocked() {
            var row = grid.getSelected();
            if (row.aae100 == '0') {
                return tz.notify('已注销的账号不能解锁账号！');
            }
            tz.confirm('确定解锁选中的用户信息吗？', function() {
                tz.ajax('/sys/user/unlocked', {
                    bsc010: row.bsc010
                }, function(obj) {
                    if (obj.success) {
                        grid.reload();
                    }
                })
            });
        }

        function onResetPassword() {
            var row = grid.getSelected();
            if (row.aae100 == '0') {
                return tz.notify('已注销的账号不能重置密码！');
            }
            tz.confirm('确定重置选中的用户信息的密码吗？', function() {
                tz.ajax('/sys/user/resetPassword', {
                    bsc010: row.bsc010
                }, function(obj) {
                    if (obj.success) {
                        grid.reload();
                    }
                })
            });
        }
    </script>
</body>
</html>